<?php

class webPageModule extends Module {
	/*
	 * 在构造函数中装载所依赖的类或其他文件
	*/
	function __construct() {
		$this->includePhp('webPage', 'webPage');
	}
	
	
	/*
	 * 调用插件资源
	*/
	public function call($user, $method, $param) {
		switch ($method) {
			case 'getWebPage':
				$id = $param->id;
				$userName = $user['userName'];
				if (!isset($id)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				if (isset($param->srcUserName)) {
					$srcUserName = $param->srcUserName;
				} else {
					$srcUserName = NULL;
				}
				webPage::getWebPageById($id, $userName, $srcUserName);
				break;
			case 'comment':
				$id = $param->id;
				$comment = $param->comment;
				$fullName = $param->fullName;
				$userName = $user['userName'];
				if (!isset($id) || $userName == '') {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				comment_by_moduleId($id, 'webPage', $comment, $userName, $fullName);
				break;
			case 'rate':
				$id = $param->id;
				$rate = (int)$param->rate;
				$userName = $user['userName'];
				if (!isset($id) || $userName == '') {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				rate_by_moduleId($id, 'webPage', $rate, $userName);
				break;
			case 'getWebPageTag':
				$tagName = $param->tagname;
				$id = $param->id;
				$start = $param->start;
				$tplid = $param->tplid =='' || $parm->tplid == 'undefined' ?1:$param->tplid;
				if (!isset($tagName) && !isset($id)) {
					Output::instance()->resultCode(code_lackof_param);
					return;
				}
				if (!isset($start)) {
					$start = 0;
				}
				$limit = 10;
				if (isset($tagName)) {
					$field = 'tagName';
					$value = $tagName;
				} else if (isset($id)) {
					$field = 'id';
					$value = $id;
				}
				webPage::getWebPageTag($field, $value, $start, $limit,$tplid);
				break;
		}
	}
	
}


$module = new webPageModule();
Module::addModule($module);
?>